#ifndef __M_LOG_H__
#define __M_LOG_H__
#include <iostream>
#include <ctime>
#define INFO 0
#define DEBUG 1
#define ERROR 2
#define LOG_DEFAULT_LEVEL INFO

#define LOG(level, format, ...)                                                                \
    do                                                                                         \
    {                                                                                          \
        if (LOG_DEFAULT_LEVEL > level)                                                         \
            break;                                                                             \
        time_t t = time(nullptr);                                                              \
        struct tm *tm = localtime(&t);                                                         \
        char timestr[64] = {0};                                                                \
        strftime(timestr, 64, "%Y/%m/%d-%H:%M:%S ", tm);                                       \
        fprintf(stdout, "[%s %s : %d]" format "\n", timestr, __FILE__, __LINE__, ##__VA_ARGS__); \
    } while (0)
#define ILOG(format, ...) LOG(INFO, format, ##__VA_ARGS__)
#define DLOG(format, ...) LOG(DEBUG, format, ##__VA_ARGS__)
#define ELOG(format, ...) LOG(ERROR, format, ##__VA_ARGS__)
#endif